package com.dq.Service.Impl;

import com.dq.Mapper.UserMapper;
import com.dq.Pojo.User;
import com.dq.Service.UserService;
import com.dq.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByusername(String username) {
        return userMapper.findByusername(username);
    }

    @Override
    public void adduser(User user) {
        //加密
        String md5String = Md5Util.getMD5String(user.getPassword());
        user.setPassword(md5String);
        userMapper.adduser(user);
    }

    @Override
    public User findByid(Integer userid) {
        return userMapper.findByid(userid);
    }

    @Override
    public void updatePwd(Integer userid, String newPassword) {
        String md5String = Md5Util.getMD5String(newPassword);
        userMapper.updatePwd(userid,md5String);
    }
}
